{layout name="layout/food" /}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">用户列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom am-cf">
                        <form class="toolbar-form" action="{:url('food.user/index')}">
                            <div class="am-u-sm-12">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <select name="gender" data-am-selected="{btnSize: 'sm', placeholder: '性别不限'}">
                                            <option value="all" <?= $gender == 'all' ?'selected':''?>>全部</option>
                                            <option value="1" <?= $gender == '1' ?'selected':''?>>先生</option>
                                            <option value="2" <?= $gender == '2' ?'selected':''?>>女士</option>
                                            <option value="0" <?= $gender == '0' ?'selected':''?>>未知</option>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="search" placeholder="请输入微信昵称、ID、手机号" value="{$search}">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search" type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>头像</th>
                                <th>昵称</th>
                                <th>性别</th>
                                <th>手机</th>
                                <th>消费</th>
								<th>余额</th>
                                <th>积分</th>
                                <th>省份</th>
                                <th>城市</th>
                                <th>平台</th>
                                <th>员工</th>
								<th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if !$list->isEmpty()}
                                {foreach $list as $item}
                                <tr>
                                    <td class="am-text-middle">{$item['user_id']}</td>
                                    <td class="am-text-middle">
                                        <img src="{$item['avatar']}" width="72" height="72" alt="">
                                    </td>
                                    <td class="am-text-middle">{$item['nickname']|default='--'}</td>
                                    <td class="am-text-middle">{$item['gender']}</td>
                                    <td class="am-text-middle">{$item['phone']}</td>
                                    <td class="am-text-middle">{$item['pay']}</td>
									<td class="am-text-middle">{$item['money']}</td>
									<td class="am-text-middle">{$item['score']}</td>
                                    <td class="am-text-middle">{$item['province']|default='--'}</td>
                                    <td class="am-text-middle">{$item['city']|default='--'}</td>
                                    <td class="am-text-middle">{$item['platform']['text']}</td>
                                    <td class="am-text-middle">
										<span class="j-staff am-badge x-cur-p {$item['is_staff']['value'] == 1 ? ' am-badge-success' : ' am-badge-warning'}" 
											 data-ids="{$item['user_id']}"
											 data-status="{$item['is_staff']['value']}">
										      {$item['is_staff']['text']}
										</span>
                                    </td>
									<td class="am-text-middle">
										<div class="tpl-table-black-operation">
                                            <a class="j-recharge tpl-table-black-operation-default"
                                                href="javascript:void(0);"
                                                title="用户充值"
                                                data-user_id="{$item['user_id']}"
                                                data-money="{$item['money']}"
												<i class="iconfont icon-qiandai"></i>充值
                                            </a>
                                        </div>
									</td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="13" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="food/user/tpl/tp_recharge" /}
<script>
    $(function () {
        
        // 切换上架状态
        $('.j-staff').click(function () {
            var data = $(this).data();
			var msg = '确定要'+(parseInt(data.status) === 1 ? '取消' : '设置为')+'员工身份？';
            var url = "{:url('food.user/staff')}";
			$('.j-staff').del('id', url,msg);
        });

        /**
         * 账户充值
         */
        $('.j-recharge').on('click', function () {
            var data = $(this).data();
            $.showAction({
                title: '余额充值', 
                area: '460px', 
                content: template('tpl-recharge', data), 
                uCheck: true, 
                success: function ($content) {
                    $('#my-form').formPost({
                        url: "{:url('food.user/recharge')}"
                    });
                }, 
                btn2: function ($content) {
                    return true;
                }
            });
        });
    });

</script>